package com.aku.service.impl;

import com.aku.dao.DoorMapper;
import com.aku.entity.Door;
import com.aku.service.DoorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DoorServiceImpl implements DoorService {

    @Resource
    private DoorMapper doorMapper;

    @Override
    public List<Door> findAllDoor() {
        List<Door> doors = doorMapper.selectAllDoor();
        return doors;
    }

    @Override
    public Door findDoorById(int id) {
        Door door = doorMapper.selectDoorById(id);
        return door;
    }

    @Override
    public boolean addDoor(Door door) {
        int isInsertDoor = doorMapper.insertDoor(door);
        return isInsertDoor > 0;
    }

    @Override
    public boolean updateDoor(Door door) {
        int isUpdateDoor = doorMapper.updateDoor(door);
        return isUpdateDoor > 0;
    }

    @Override
    public boolean removeDoorById(int id) {
        int isDeleteDoorById = doorMapper.deleteDoorById(id);
        return isDeleteDoorById > 0;
    }
}
